// search模块的小仓库
// state：仓库存储数据的地方
import {reqGetSearchInfo} from '@/api/index'
const state = {
    searchList: {},
}
// mutations: 修改state的唯一手段
const mutations = {
    GETSEARCHLIST(state, list) {
        state.searchList = list
    }
}

// action: 书写业务逻辑，也可以处理异步
const actions={
    async getSearchList({commit}, params={}) {
       let result = await reqGetSearchInfo(params)
       commit('GETSEARCHLIST', result.data)
    }
}

// getters: 可以理解为计算属性，用于简化仓库数据，让组件获取仓库的数据更加方便
const getters={
    goodList(state){
        return state.searchList.goodsList || []
    },
    trademarkList(state){
        return state.searchList.trademarkList || []
    },
    attrsList(state){
        return state.searchList.attrsList || []
    },
}

export default {
    state,
    mutations,
    actions,
    getters
}
